<template>
	<view class="Fans">
		<view class="item" v-for="i in consten" :key="i">
			<view class="yuan" v-if="i.is_read==1"></view>
			<image :src="i.avater||'/pagesB/static/微信图片_20201124091755.png'"></image>
			<view class="item_content">
				<view class="title">{{i.title}}</view>
				<view class="time">{{i.date_add}}</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
			return {
				consten: [],
				model:'',
				access_token:''
			};
		},
		onShow() {
			let _this=this
			uni.getSystemInfo({
			    success: function (res) {
					_this.model=res.model
			    }
			});
			if(uni.getStorageSync('access_token')){
			this.access_token=JSON.parse(uni.getStorageSync('access_token'))
			}
			this.$request('/app/message/getAttentionMessages', 'post', {
				page: this.page,
				t:this.model,
				access_token:this.access_token
			}).then(res => {
				if(res.errcode==0){
					function dateTO(data) {
						//data为时间戳
						var date = new Date(data);
						var Y = date.getFullYear() + '-';
						var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
						var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
						var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
						var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
						var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
						var strDate = Y + M + D + h + m + s; //转换为年月日时分秒
						// var strDate = Y + M + D; //转换为年月日
						return strDate;
					}
					res.content.forEach(v=>{
						v.date_add=dateTO(v.date_add * 1000)
					})
					this.consten=res.content
					}
			})
		},
		onReachBottom(){
			this.page=this.page++
			this.$request('/app/message/getAttentionMessage', 'post', {
				page: this.page,
				t:this.model,
				access_token:this.access_token
			}).then(res => {
				if(res.data.errcode==0){
					function dateTO(data) {
						//data为时间戳
						var date = new Date(data);
						var Y = date.getFullYear() + '-';
						var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
						var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
						var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
						var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
						var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
						var strDate = Y + M + D + h + m + s; //转换为年月日时分秒
						// var strDate = Y + M + D; //转换为年月日
						return strDate;
					}
					res.content.forEach(v=>{
						v.date_add=dateTO(v.date_add * 1000)
					})
					res.data.content.forEach(v=>{
					this.consten.push(v)
		
					})
					}
			})
		}
	};
</script>

<style lang="less" scoped>
.Fans {
	height: 100%;
	background-color: #f3f4f5;
	padding-top: 20rpx;
	overflow-x: scroll;
	.item{
		padding: 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-bottom: 20rpx;
		background-color: #fff;
		.yuan{
			width: 18rpx;
			height: 18rpx;
			background: #DB1B22;
			border-radius: 50%;
		}
		image{
			height: 80rpx;
			width: 80rpx;
			border-radius: 20px;
			margin: 0 20rpx;
		}
		.item_content{
			flex: 1;
			.title{
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #111111;
				margin-bottom: 10rpx;
			}
			.time{
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #9DA5A8;
			}
		}
	}
}
</style>
